﻿using Domain.Infrastructure;

namespace Application.Infrastructure
{
    /// <summary>
    /// 具有（创建、更新）约束的 服务基类
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class BaseService_C_M<T> : BaseService_C<T> where T : class, ICreationAudited, IModifyAudited, new()
    {
        public BaseService_C_M(ILog log, IRepositoryBase<T> repository) : this(log, repository, "")
        {
        }

        public BaseService_C_M(ILog log, IRepositoryBase<T> repository, string userId) : base(log, repository, userId)
        {
        }
        public override bool Update(T entity)
        {
            entity.Modify(UserId, ((IModifyAudited)entity).Id);
            return Repository.Update(entity);
        }
    }
}
